<template>
  <div style="background-color: #ffffff;padding: 40px 0px 30px 150px;width: 90%;margin: 0 auto;box-shadow:1px 1px 10px #8c939d;" >
  <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px" >
      <el-form-item label-width="400px" label="库存盘点单关联盘点任务后，是否显示盘点任务中的商品数据:" prop="field105">
        <el-select v-model="formData.showProduct" placeholder="请选择库存盘点单关联盘点任务后，是否显示盘点任务中的商品数据" clearable
          :style="{width: '30%'}">
          <el-option v-for="(item, index) in field105Options" :key="index" :label="item.label"
            :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label-width="400px" label="库存盘点单是否显示盘点任务创建时商品的系统库存数量:" prop="field106">
        <el-select v-model="formData.showStock" placeholder="请选择库存盘点单是否显示盘点任务创建时商品的系统库存数量" clearable
          :style="{width: '30%'}">
          <el-option v-for="(item, index) in field106Options" :key="index" :label="item.label"
            :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label-width="400px" label="盘点差异生成时是否自动调整盘点任务中商品的系统库存数量:" prop="field108">
        <el-select v-model="formData.autoChangeStock" placeholder="请选择盘点差异生成时是否自动调整盘点任务中商品的系统库存数量" clearable
          :style="{width: '30%'}">
          <el-option v-for="(item, index) in field108Options" :key="index" :label="item.label"
            :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label-width="400px" label="盘点差异单中的盘点数量是否允许手动修改:" prop="field109">
        <el-select v-model="formData.allowChangeNum" placeholder="请选择盘点差异单中的盘点数量是否允许手动修改" clearable
          :style="{width: '30%'}">
          <el-option v-for="(item, index) in field109Options" :key="index" :label="item.label"
            :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label-width="400px" label="盘点任务自动作废时间:" prop="field113">
        <el-input v-model="formData.cancelHours" placeholder="请选择盘点任务自动作废时间" clearable :style="{width: '30%'}">
          <template slot="append">小时</template>
        </el-input>
      </el-form-item>
      <el-form-item size="large" label-width="400px" >
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { get, update } from "@/api/system/takeStockConfig";

export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        id : 1,
        showProduct: 0,
        showStock: 0,
        autoChangeStock: 0,
        allowChangeNum: 0,
        cancelHours: 0,
      },
      rules: {
        showProduct: [{
          required: true,
          message: '请选择库存盘点单关联盘点任务后，是否显示盘点任务中的商品数据',
          trigger: 'change'
        }],
        showStock: [{
          required: true,
          message: '请选择库存盘点单是否显示盘点任务创建时商品的系统库存数量',
          trigger: 'change'
        }],
        autoChangeStock: [{
          required: true,
          message: '请选择盘点差异生成时是否自动调整盘点任务中商品的系统库存数量\n',
          trigger: 'change'
        }],
        allowChangeNum: [{
          required: true,
          message: '请选择盘点差异单中的盘点数量是否允许手动修改',
          trigger: 'change'
        }],
        cancelHours: [{
          required: true,
          message: '请选择盘点任务自动作废时间',
          trigger: 'change'
        }],
      },
      field105Options: [{
        "label": "显示",
        "value": 1
      }, {
        "label": "不显示",
        "value": 0
      }],
      field106Options: [{
        "label": "显示",
        "value": 1
      }, {
        "label": "不显示",
        "value": 0
      }],
      field108Options: [{
        "label": "调整",
        "value": 1
      }, {
        "label": "不调整",
        "value": 0
      }],
      field109Options: [{
        "label": "允许",
        "value": 1
      }, {
        "label": "不允许",
        "value": 0
      }],
      field113Options: [{
        "label": "是",
        "value": 1
      }, {
        "label": "否",
        "value": 0
      }],
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getInfo();
  },
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (valid) {
          update(this.formData).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.getInfo();
          });
        }
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    getInfo(){
      get().then(res => {
        this.formData = res.data;
        console.log(this.formData)
      })
    },
  }
}

</script>
<style>

</style>
